{
    "cells": [
        {
            "cell_type": "markdown",
            "id": "23d11083",
            "metadata": {},
            "source": [
                "\n",
                "Copyright(c) 2025 NVIDIA Corporation. All rights reserved.\n",
                "\n",
                "NVIDIA Corporation and its licensors retain all intellectual property\n",
                "and proprietary rights in and to this software, related documentation\n",
                "and any modifications thereto.Any use, reproduction, disclosure or\n",
                "distribution of this software and related documentation without an express\n",
                "license agreement from NVIDIA Corporation is strictly prohibited."
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "# Pick the LLM for the Digital Human\n",
                "\n",
                "This notebook outlines the step-by-step process to change the default LLM for the digital human to a compatible LLM of choice. "
            ]
        },
        {
            "cell_type": "markdown",
            "id": "8c703997",
            "metadata": {},
            "source": [
                "### Ensure that the Pre-requisites are met\n",
                "\n",
                "Please run through the steps noted in the setup prequisites notebook to ensure that you have the necessary setup in place.\n",
                "\n",
                "Check the status of the application again by running the following command. \n",
                "\n",
                "Note: You will need to select the python environment to run the notebook for the first time. "
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "3ed5d0aa",
            "metadata": {},
            "outputs": [],
            "source": [
                "!kubectl get po -n app"
            ]
        },
        {
            "cell_type": "markdown",
            "id": "acea0eb6",
            "metadata": {},
            "source": [
                "### Download the ACE Controller Configuration\n",
                "* Ensure that the downloaded ACE Controller configuration is in sync. You can click on the download button again to download the latest version of the configuration. "
            ]
        },
        {
            "cell_type": "markdown",
            "id": "65714f40",
            "metadata": {},
            "source": [
                "![ACE Configurator](pictures/ace_configurator_sync.png)"
            ]
        },
        {
            "cell_type": "markdown",
            "id": "9ec6fffb",
            "metadata": {},
            "source": [
                "### Edit the `config.yaml` file\n",
                "1. Navigate to the following path in your file system:\n",
                "   ```\n",
                "   ace-controller-ace-controller-deployment -> assets -> app-storage-volume -> configs -> config.yaml\n",
                "   ```\n",
                "2. Open the `config.yaml` file.\n",
                "3. Update the following sections:\n",
                "   - **LLM**: Modify the NIM LLM model to a compatible LLM of your choice. Example: `mistralai/mistral-7b-instruct-v0.3`\n",
                "   - Some of the other NIM LLM models you can try are: \n",
                "      * meta/llama-3.2-3b-instruct\n",
                "      * nvidia/nemotron-mini-4b-instruct\n",
                "      * nvidia/llama-3.1-nemotron-70b-instruct\n",
                "\n",
                "   ```"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "cb211814",
            "metadata": {
                "vscode": {
                    "languageId": "plaintext"
                }
            },
            "outputs": [],
            "source": [
                "# Example snippet of `config.yaml`\n",
                " NvidiaLLMService:\n",
                "    model: \"mistralai/mistral-7b-instruct-v0.3\""
            ]
        },
        {
            "cell_type": "markdown",
            "id": "71b5855c",
            "metadata": {},
            "source": [
                "### Upload the Changes\n",
                "Save your local changes in VSCode. \n",
                "In the ACE Configurator view in VSCode, click the **Upload** button to upload the modified `config.yaml` file."
            ]
        },
        {
            "cell_type": "markdown",
            "id": "b973a77c",
            "metadata": {},
            "source": [
                "![Avatar Controller Upload Config](pictures/upload_config.png)"
            ]
        },
        {
            "cell_type": "markdown",
            "id": "103ef74c",
            "metadata": {},
            "source": [
                "Ensure that the changes are finished updating. This might take a few seconds.\n",
                "\n",
                "Once the changes are successfully updated. the ACE Configurator view will show a green `Synced` symbol again for the app-storage-volume. "
            ]
        },
        {
            "cell_type": "markdown",
            "id": "74a52d03",
            "metadata": {},
            "source": [
                "![Avatar Controller Upload Config](pictures/ace-configurator-synced.png)"
            ]
        },
        {
            "cell_type": "markdown",
            "id": "bc1c2bd4",
            "metadata": {},
            "source": [
                "### Refresh the Browser UI\n",
                "1. Open the browser UI where the digital human is hosted. (your current URL:30111)\n",
                "2. Refresh the page.\n",
                "3. Start a conversation with the digital human, and you should see it introducing itself/fetching responses from the updated LLM. "
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "### Test the Updated Digital Human Behavior\n",
                "Start a conversation with the digital human in the refreshed UI. Observe whether the digital human responds with the expected behavior based on the updated LLM model.\n",
                "\n",
                "Note: The difference might not be very noticeable, but you can try different LLM models to see the difference in behavior. "
            ]
        },
        {
            "cell_type": "markdown",
            "id": "44d4c54c",
            "metadata": {},
            "source": [
                "### Conclusion\n",
                "You have successfully reconfigured the ACE digital human and tested the changes. 🎉"
            ]
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": "base",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.11.5"
        }
    },
    "nbformat": 4,
    "nbformat_minor": 5
}
